package echo;



/**
 * The test class CalculadoraTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class CalculadoraTest extends junit.framework.TestCase
{
    private echo.Calculadora calculad1;

    /**
     * Default constructor for test class CalculadoraTest
     */
    public CalculadoraTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    protected void setUp()
    {
        calculad1 = new echo.Calculadora();
        
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    protected void tearDown()
    {
    }

    public void testeEntra1()
    {
        calculad1.limpa();        
        assertEquals("1", calculad1.entraUm());
    }

    public void testaEntra11()
    {
        calculad1.limpa();        
        calculad1.entraUm();
        assertEquals("11", calculad1.entraUm());
    }

    public void testaEntra111()
    {
        calculad1.limpa();
        calculad1.entraUm();
        calculad1.entraUm();
        assertEquals("111", calculad1.entraUm());
    }

    public void testaLimpaSoma()
    {
        calculad1.limpa();
        assertEquals("0", calculad1.comandoSoma());
    }

    public void testaEntra1Soma()
    {
        calculad1.limpa();      
        calculad1.entraUm();
        assertEquals("1", calculad1.comandoSoma());
    }

    public void testaEntra1SomaEntra1Soma()
    {
        calculad1.limpa();
        calculad1.entraUm();
        calculad1.comandoSoma();
        calculad1.entraUm();
        assertEquals("2", calculad1.comandoSoma());
    }

    public void testaEntra111SomaEntra11SomaEntra1Soma()
    {
        calculad1.limpa();
        calculad1.entraUm();
        calculad1.entraUm();
        calculad1.entraUm();
        calculad1.comandoSoma();
        calculad1.entraUm();
        calculad1.entraUm();
        calculad1.comandoSoma();
        calculad1.entraUm();
        assertEquals("123", calculad1.comandoSoma());
    }

    public void testaBinEntra1()
    {
        calculad1.limpa();
        calculad1.modoBin();
        assertEquals("0b1", calculad1.entraUm());
    }
    
    public void testaBinEntra1SomaEntra1Soma()
    {
        calculad1.limpa();
        calculad1.modoBin();
        calculad1.entraUm();
        calculad1.comandoSoma();
        calculad1.entraUm();
        assertEquals("0b10", calculad1.comandoSoma());
    }

    public void testaEntra1SomaBinEntra1Soma()
    {
        calculad1.limpa();
        calculad1.entraUm();
        calculad1.comandoSoma();        
        calculad1.modoBin();
        calculad1.entraUm();
        assertEquals("0b10", calculad1.comandoSoma());
    }   
    
    // b1h1 -> 0x11    
    public void testEntraUmBinarioHexa()
    {
        calculad1.limpa();
        calculad1.modoBin();    
        calculad1.entraUm();
        calculad1.modoHex();
        assertEquals("0x11",  calculad1.entraUm());        
    }

    //b1h1b1 -> 0b100011
    public void testEntraUmBinarioHexaBinario()
    {
        calculad1.limpa();
        calculad1.modoBin();    
        calculad1.entraUm();    //0b1
        calculad1.modoHex();    //0x1
        calculad1.entraUm();    //0x11       
        calculad1.modoBin();    //0b10001
        assertEquals("0b100011",  calculad1.entraUm()); 
    } 
    
    //b1h1d1 -> 171 
    public void testEntraUmBinarioHexaDecimal()
    {
        calculad1.limpa();
        calculad1.modoBin();    
        calculad1.entraUm();    //0b1
        calculad1.modoHex();    //0x1
        calculad1.entraUm();    //0x11       
        calculad1.modoDec();    //17
        assertEquals("171",  calculad1.entraUm()); 
    }    
    
    //b1+h1+d1+ -> 3
    public void testSomaBinarioHexaDecimal()
    {
        calculad1.limpa();
        calculad1.modoBin();        //0b0
        calculad1.entraUm();        //0b1
        calculad1.comandoSoma();    //0b1 (1)        
        calculad1.modoHex();        //0x1
        calculad1.entraUm();        //0x1
        calculad1.comandoSoma();    //0x2 (2)
        calculad1.modoDec();        //2
        calculad1.entraUm();        //1
        assertEquals("3", calculad1.comandoSoma()); 
    }  
    
    //b11+h11+d11+ -> 31
    public void testSomaBinarioHexaDecimal1()
    {
        calculad1.limpa();
        calculad1.modoBin();        //0b0
        calculad1.entraUm();        //0b1
        calculad1.entraUm();        //0b11        
        calculad1.comandoSoma();    //0b11 (3)
        calculad1.modoHex();        //0x0
        calculad1.entraUm();        //0x1
        calculad1.entraUm();        //0x11        
        calculad1.comandoSoma();    //0x14 (20)
        calculad1.modoDec();        //0
        calculad1.entraUm();        //1
        calculad1.entraUm();        //11        
        assertEquals("31", calculad1.comandoSoma()); 
    }   
    
    //b111+h111+d111+ -> 391 
    public void testSomaBinarioHexaDecimal11()
    {
        calculad1.limpa();
        calculad1.modoBin();        //0b0
        calculad1.entraUm();        //0b1
        calculad1.entraUm();        //0b11        
        calculad1.entraUm();        //0b111 (7)       
        calculad1.comandoSoma();    //0b111 (7)
        calculad1.modoHex();        //0x0
        calculad1.entraUm();        //0x1
        calculad1.entraUm();        //0x11        
        calculad1.entraUm();        //0x111 (273)               
        calculad1.comandoSoma();    //0x... (280) 
        calculad1.modoDec();        //0
        calculad1.entraUm();        //1
        calculad1.entraUm();        //11      
        calculad1.entraUm();        //111                
        assertEquals("391", calculad1.comandoSoma()); 
    }   
    
    //b11+h11+ -> 0x14
    public void testSomaBinarioHexaDoisAlgarismos()
    {
        calculad1.limpa();
        calculad1.modoBin();        //0b0
        calculad1.entraUm();        //0b1
        calculad1.entraUm();        //0b11        
        calculad1.comandoSoma();    //0b11 (3)
        calculad1.modoHex();        //0x0
        calculad1.entraUm();        //0x1
        calculad1.entraUm();        //0x11 (17)        
        assertEquals("0x14", calculad1.comandoSoma()); 
    }  
    
    //b1+h1+ -> 0x2
    public void testSomaBinarioHexaUmAlgarismo()
    {
        calculad1.limpa();
        calculad1.modoBin();        //0b0
        calculad1.entraUm();        //0b1
        calculad1.comandoSoma();    //0b1 (1)
        calculad1.modoHex();        //0x0
        calculad1.entraUm();        //0x1 (1)
        assertEquals("0x2", calculad1.comandoSoma()); 
    } 
    
    //b1+1+ -> 0b10
    public void testSomaSomenteBinario()
    {
        calculad1.limpa();
        calculad1.modoBin();        //0b0
        calculad1.entraUm();        //0b1
        calculad1.comandoSoma();    //0b1 (1)
        calculad1.entraUm();        //0b1 (1)
        assertEquals("0b10", calculad1.comandoSoma()); 
    } 

    //b11+11+ -> 0b110
    public void testSomaSomenteBinarioDoisAlgarismos()
    {
        calculad1.limpa();
        calculad1.modoBin();        //0b0
        calculad1.entraUm();        //0b1
        calculad1.entraUm();        //0b11        
        calculad1.comandoSoma();    //0b11 (3)
        calculad1.entraUm();        //0b1 (1)
        calculad1.entraUm();        //0b11 (3)        
        assertEquals("0b110", calculad1.comandoSoma()); 
    }   
  
    //b111+111+ -> 0b1110
    public void testSomaSomenteBinarioTresAlgarismos() 
    {
        calculad1.limpa();
        calculad1.modoBin();        //0b0
        calculad1.entraUm();        //0b1
        calculad1.entraUm();        //0b11        
        calculad1.entraUm();        //0b11                
        calculad1.comandoSoma();    //0b111 (7)
        calculad1.entraUm();        //0b1 (1)
        calculad1.entraUm();        //0b11 (3)        
        calculad1.entraUm();        //0b111 (7)                
        assertEquals("0b1110", calculad1.comandoSoma()); 
    }   
    
    //h1+1+ -> 0x2
    public void testSomaSomenteHexa()
    {
        calculad1.limpa();
        calculad1.modoHex();        //0x0
        calculad1.entraUm();        //0x1
        calculad1.comandoSoma();    //0x1 (1)
        calculad1.entraUm();        //0x1 (1)
        assertEquals("0x2", calculad1.comandoSoma()); 
    } 

    //h11+11+ -> 0x22 
    public void testSomaSomenteHexaDoisAlgarismos()
    {
        calculad1.limpa();
        calculad1.modoHex();        //0x0
        calculad1.entraUm();        //0x1
        calculad1.entraUm();        //0x11        
        calculad1.comandoSoma();    //0x11 (17)
        calculad1.entraUm();        //0x1
        calculad1.entraUm();        //0x11 (17)        
        assertEquals("0x22", calculad1.comandoSoma()); 
    }   
    
    //h1+111+ -> 0x112 
    public void testSomaSomenteHexaTresAlgarismos() 
    {
        calculad1.limpa();
        calculad1.modoHex();        //0x0
        calculad1.entraUm();        //0x1
        calculad1.comandoSoma();    //0x1 (1)
        calculad1.entraUm();        //0x1 
        calculad1.entraUm();        //0x11         
        calculad1.entraUm();        //0x111 (273)
        assertEquals("0x112", calculad1.comandoSoma()); 
    }      
    
    public void testEntraISoma()
    {
        calculad1.limpa();
        calculad1.entraI();
        assertEquals("0", calculad1.comandoSoma());         
    }
    
    public void testEntraUmEntraISoma()
    {
        calculad1.limpa();
        calculad1.entraUm();
        calculad1.entraI();
        assertEquals("1", calculad1.comandoSoma());         
    }

    public void testEntraIEntraUmSoma()
    {
        calculad1.limpa();
        calculad1.entraI();
        calculad1.entraUm();
        assertEquals("0I1", calculad1.comandoSoma());         
    }    

    public void testEntraUmEntraIEntraUmSoma()
    {
        calculad1.limpa();
        calculad1.entraUm();        
        calculad1.entraI();
        calculad1.entraUm();
        assertEquals("1I1", calculad1.comandoSoma());         
    }        
    
    public void testEntraUmSomaEntraIEntraUmSoma()
    {
        calculad1.limpa();
        calculad1.entraUm();        
        calculad1.comandoSoma();         
        calculad1.entraI();
        calculad1.entraUm();
        assertEquals("1I1", calculad1.comandoSoma());         
    }     
    
    //Teste: somar b11111id11+h111ib111+ -> 0b100110000I0b10010     
    public void testeSoma0b11111ID11e0x111I0b111()
    {
        calculad1.limpa();
        
        calculad1.modoBin(); //b11111
        calculad1.entraUm();  
        calculad1.entraUm();  
        calculad1.entraUm();  
        calculad1.entraUm();  
        calculad1.entraUm();          
        calculad1.entraI();  //id11                  
        calculad1.modoDec();      
        calculad1.entraUm();  
        calculad1.entraUm(); //b11111id11          
        
        calculad1.comandoSoma(); 
        
        calculad1.modoHex(); //h111
        calculad1.entraUm();  
        calculad1.entraUm();  
        calculad1.entraUm(); 
        calculad1.entraI();  //ib111                 
        calculad1.modoBin();       
        calculad1.entraUm();  
        calculad1.entraUm();  
        calculad1.entraUm(); //h111ib111
        
        assertEquals("0b100110000I0b10010", calculad1.comandoSoma());         
    } 

    //Teste: somar h11+Ib11+ -> 0b10001I0b11 
    public void testeSoma0x11eI0b11()
    {
        calculad1.limpa();
        
        calculad1.modoHex();        
        calculad1.entraUm(); 
        calculad1.entraUm();         
    
        calculad1.comandoSoma(); 
   
        calculad1.entraI();  
        calculad1.modoBin();          
        calculad1.entraUm();           
        calculad1.entraUm();                   
        
        assertEquals("0b10001I0b11", calculad1.comandoSoma());   
    }

    //Teste: somar 11id1+id1+ -> 11I2 
    public void testeSomaD11ID1eID1() 
    {
        calculad1.limpa();
        
        calculad1.entraUm(); 
        calculad1.entraUm();         
        calculad1.entraI();  
        calculad1.modoDec();          
        calculad1.entraUm();         
        
        calculad1.comandoSoma();         
        
        calculad1.entraI();  
        calculad1.modoDec();         
        calculad1.entraUm();
        
        assertEquals("11I2", calculad1.comandoSoma());                 
    }    

    //Teste: somar 1i1+1+ -> 2I1
    public void testeSomaD1ID1eD1()    
    {
        calculad1.limpa();
        
        calculad1.entraUm(); 
        calculad1.entraI();  
        calculad1.entraUm(); 
        
        calculad1.comandoSoma();         
        
        calculad1.entraUm();
        
        assertEquals("2I1", calculad1.comandoSoma());                 
    }    

    //Teste: somar Ib11+Ih11 -> 0x0I0x14 
    public void testeSomaI0b11eI0x11()   
    {
        calculad1.limpa();
   
        calculad1.entraI(); 
        calculad1.modoBin();          
        calculad1.entraUm();           
        calculad1.entraUm();          
     
        calculad1.comandoSoma();         
        
        calculad1.entraI(); 
        calculad1.modoHex();          
        calculad1.entraUm();           
        calculad1.entraUm();  
        
        assertEquals("0x0I0x14", calculad1.comandoSoma());                 
    }    
       
}









